


public class GraphicTest {
	
	private static final int testno = 1;
	
	public static void main(String[] argv){
		
		Calculator calc = new Calculator();
		FuzzyNumber num3;
		GeneralSegment seglist1;
		FuzzyNumber num1;
		GeneralSegment seglist2;
		FuzzyNumber num2;
		switch(testno){
			case 1:	
				seglist1 = new GeneralSegment();
				seglist1.add(new Segment(new Point(1,0),new Point(2,1)));
				seglist1.add(new Segment(new Point(2,1),new Point(4,1)));
				seglist1.add(new Segment(new Point(4,1),new Point(6,0)));
				num1 = new FuzzyNumber(seglist1);
				
				seglist2 = new GeneralSegment();
			    seglist2.add(new Segment(new Point(1,0),new Point(3,0)));
			    seglist2.add(new Segment(new Point(3,0),new Point(3,1)));
				seglist2.add(new Segment(new Point(3,1),new Point(4,1)));
				seglist2.add(new Segment(new Point(4,1),new Point(4,0)));
				seglist2.add(new Segment(new Point(4,0),new Point(6,0)));
				num2 = new FuzzyNumber(seglist2);
				
				try {
					num3 = calc.addFN(num1, num2);
					ResultFrame rfadd1 = new ResultFrame(num1,num1,num1);
					ResultFrame rfadd2 = new ResultFrame(num2,num2,num2);
					ResultFrame rfadd3 = new ResultFrame(num3,num3,num3);

					num3 = calc.substractFN(num1, num2);
					
					num3 = calc.multiplyFN(num1, num2);
					
					num3 = calc.divideFN(num1, num2);
					
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				break;
				
			case 2:
				seglist1 = new GeneralSegment();
				seglist1.add(new Segment(new Point(1,0),new Point(2,1)));
				seglist1.add(new Segment(new Point(2,1),new Point(4,1)));
				seglist1.add(new Segment(new Point(4,1),new Point(6,0)));
				num1 = new FuzzyNumber(seglist1);
				
				seglist2 = new GeneralSegment();
			    seglist2.add(new Segment(new Point(3,0),new Point(4,1)));
				seglist2.add(new Segment(new Point(4,1),new Point(5,1)));
				seglist2.add(new Segment(new Point(5,1),new Point(6,0.3)));
				seglist2.add(new Segment(new Point(6,0.3),new Point(6.5,0.3)));
				seglist2.add(new Segment(new Point(6.5,0.3),new Point(7,0.7)));
				seglist2.add(new Segment(new Point(7,0.7),new Point(8,0.7)));
				seglist2.add(new Segment(new Point(8,0.7),new Point(10,0)));
				num2 = new FuzzyNumber(seglist2);
				
				try {
					num3 = calc.substractFN(num2, num1);
					ResultFrame rfsub1 = new ResultFrame(num1,num1,num1);
					ResultFrame rfsub2 = new ResultFrame(num2,num2,num2);
					ResultFrame rfsub3 = new ResultFrame(num3,num3,num3);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				break;
				
			case 3:
				seglist1 = new GeneralSegment();
				seglist1.add(new Segment(new Point(1,0),new Point(2,1)));
				seglist1.add(new Segment(new Point(2,1),new Point(4,1)));
				seglist1.add(new Segment(new Point(4,1),new Point(6,0)));
				num1 = new FuzzyNumber(seglist1);
				
				seglist2 = new GeneralSegment();
			    seglist2.add(new Segment(new Point(3,0),new Point(3,1)));
				seglist2.add(new Segment(new Point(3,1),new Point(3,1)));
				seglist2.add(new Segment(new Point(3,1),new Point(3,0)));
				seglist2.add(new Segment(new Point(5,0),new Point(5,0.5)));
				seglist2.add(new Segment(new Point(5,0.5),new Point(6,0.5)));
				seglist2.add(new Segment(new Point(6,0.5),new Point(6,0)));
				num2 = new FuzzyNumber(seglist2);
				
				try {
					num3 = calc.multiplyFN(num1, num2);
					ResultFrame rfmul1 = new ResultFrame(num1,num1,num1);
					ResultFrame rfmul2 = new ResultFrame(num2,num2,num2);
					ResultFrame rfmul3 = new ResultFrame(num3,num3,num3);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				break;
				
			case 4:
				seglist1 = new GeneralSegment();
				seglist1.add(new Segment(new Point(1,0),new Point(2,1)));
				seglist1.add(new Segment(new Point(2,1),new Point(4,1)));
				seglist1.add(new Segment(new Point(4,1),new Point(6,0)));
				num1 = new FuzzyNumber(seglist1);
				
				seglist2 = new GeneralSegment();
			    seglist2.add(new Segment(new Point(3,0),new Point(3,1)));
				seglist2.add(new Segment(new Point(3,1),new Point(3,1)));
				seglist2.add(new Segment(new Point(3,1),new Point(3,0)));
				seglist2.add(new Segment(new Point(3,0),new Point(5,0)));
				seglist2.add(new Segment(new Point(5,0),new Point(5,0.5)));
				seglist2.add(new Segment(new Point(5,0.5),new Point(6,0.5)));
				seglist2.add(new Segment(new Point(6,0.5),new Point(6,0)));
				num2 = new FuzzyNumber(seglist2);
				
				try {
					num3 = calc.divideFN(num1, num2);
					ResultFrame rfdiv1 = new ResultFrame(num1,num1,num1);
					ResultFrame rfdiv2 = new ResultFrame(num2,num2,num2);
					ResultFrame rfdiv3 = new ResultFrame(num3,num3,num3);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				break;
		}		
	}
	
}
